package tool

import (
	"context"
	"fmt"
	"github.com/jackc/pgx/v5/pgxpool"
	"os"
)

var DbPool *pgxpool.Pool

func init() {
	var err error
	DbPool, err = pgxpool.New(context.Background(), "postgres://test:test@8.142.102.189:5432/test")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err)
		os.Exit(1)
	}

	//row := DbPool.QueryRow(context.Background(), "select account,password from chat_user where account='admin'")
	//if err != nil {
	//	fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
	//	os.Exit(1)
	//}
	//
	//var account, password string
	//row.Scan(&account, &password)
	//fmt.Println(account, password)
	fmt.Println("DB Connected")
}
